{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Visualizing a Lattice\n",
    "\n",
    "You can view the transport graph of a lattice in the Covalent GUI after you send the lattice to the Covalent dispatcher. Sometimes though you'll want to view the lattice structure before you run it or before it's even completed. The Covalent `Lattice` class contains a function that enables you to view a lattice at any time without dispatching it."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Prerequisites\n",
    "\n",
    "1. [Restart Covalent](../execution/covalent_cli.rst). \n",
    "\n",
    "2. [Define a lattice](./construct_lattice.ipynb)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "import covalent as ct\n",
    "\n",
    "\n",
    "@ct.electron\n",
    "def identity(x):\n",
    "    return x\n",
    "\n",
    "\n",
    "@ct.electron\n",
    "def square(x):\n",
    "    return x * x\n",
    "\n",
    "\n",
    "@ct.lattice\n",
    "def workflow(a):\n",
    "    val_1 = identity(x=a)\n",
    "    return square(x=val_1)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Procedure\n",
    "\n",
    "To view a lattice at any stage:\n",
    "\n",
    "1. Run the Covalent `lattice.draw()` function."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "workflow.draw(3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2. In the Covalent GUI, go to the [Lattice Draw Preview](../../webapp_ui/preview/index.rst) page.\n",
    "\n",
    "![Lattice Graph](./images/visualize_lattice.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### See Also\n",
    "\n",
    "[Managing Covalent](../execution/covalent_cli.rst)\n",
    "\n",
    "[Defining a Lattice](./construct_lattice.ipynb)\n",
    "\n",
    "[Adding Electrons to Lattices](./add_electron_to_lattice.ipynb)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
